import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';

import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

import { WechatProvider } from '../providers/wechat/wechat';
import { UnitsProvider } from '../providers/units/units';
import { CodepushProvider } from '../providers/codepush/codepush';
import { JpushProvider } from '../providers/jpush/jpush';
import { JmessageProvider } from "../providers/jmessage/jmessage";

@Component({
	templateUrl: 'app.html'
})
export class MyApp {

	public rootPage: any;

	constructor(
		public platform: Platform,
		public statusBar: StatusBar,
		public splashScreen: SplashScreen,
		public wechat: WechatProvider,
		public units: UnitsProvider,
		public codepush: CodepushProvider,
		public jpush: JpushProvider,
		public jmessage: JmessageProvider) {
		this.platform.ready().then(() => {
			// Okay, so the platform is ready and our plugins are available.
			// Here you can do any higher level native things you might need.
			let that = this;
			// 判断微信页面
			if (that.units.isWechat()) {
				that.wechat.wechat_login();
			}
			//判断是否已经登陆
			that.rootPage = "TabsPage";
			//格式化
			if (that.platform.is('cordova')) {
				//状态栏
				that.statusBar.styleLightContent();
				that.splashScreen.hide();
				//app更新
				that.codepush.initCodePush();
				//极光推送
				that.jpush.initJpush();
				that.jpush.receiveNotification();
				that.jpush.openNotification();
				//极光IM
				that.jmessage.initJmessage(function(){
					//初始化成功
				});
			}
		});
	}
}